package impl

import (
	"hundsun.com/hsl/hschain/protos"
	"hundsun.com/hsl/hschain/protos/common"
	pbledger "hundsun.com/hsl/hschain/protos/ledger"
	"hundsun.com/hsl/hschain/store/extend/ledger"
)

// ProcQueryTxMsg 处理交易查询
func (chain *BlockChain) ProcQueryTxMsg(reqHashes *common.ReqHashes) ([]*pbledger.ExecutedTransaction, error) {
	service, err := ledger.NewLedger(chain.blockStore.ledgerDB)
	if err != nil {
		return nil, err
	}

	var reqs []protos.Hash
	for _, hash := range reqHashes.GetHashes() {
		reqs = append(reqs, hash)
	}

	executedTx, err := service.GetTransactions(reqs)
	if err != nil {
		return nil, err
	}
	return executedTx, nil
}
